import { createRouter, createWebHistory } from 'vue-router'
import HomePage from '@/pages/HomePage.vue'
import NoAuthPage from '@/pages/NoAuthPage.vue'
import UserLoginPage from '@/pages/user/UserLoginPage.vue'
import UserManagePage from '@/pages/admin/UserManagePage.vue'
import UserRegisterPage from '@/pages/user/UserRegisterPage.vue'
import ACCESS_ENUM from '@/access/accessEnum'
import AddPicturePage from '@/pages/picture/AddPicturePage.vue'
import PictureManagePage from '@/pages/admin/PictureManagePage.vue'
import PictureDetailPage from '@/pages/picture/PictureDetailPage.vue'
import AddPictureBatchPage from '@/pages/picture/AddPictureBatchPage.vue'

const router = createRouter({
    history: createWebHistory(import.meta.env.BASE_URL),
    routes: [
        {
            path: '/',
            name: 'home',
            component: HomePage,
        },
        {
            path: '/noAuth',
            name: '无权限',
            component: NoAuthPage,
        },
        {
            path: '/user/login',
            name: '用户登录',
            component: UserLoginPage,
        },
        {
            path: '/user/register',
            name: '用户注册',
            component: UserRegisterPage,
        },
        {
            path: '/add_picture',
            name: '创建图片',
            component: AddPicturePage,
        },
        {
            path: '/add_picture/batch',
            name: '批量创建图片',
            component: AddPictureBatchPage,
        },
        {
            path: '/admin/pictureManage',
            name: '图片管理',
            component: PictureManagePage,
            meta: {
                access: ACCESS_ENUM.ADMIN
            }
        },
        {
            path: '/picture/:id',
            name: '图片详情',
            component: PictureDetailPage,
            props: true,
        },
        {
            path: '/admin/userManage',
            name: '用户管理',
            component: UserManagePage,
            meta: {
                access: ACCESS_ENUM.ADMIN
            },
        },
        {
            path: '/about',
            name: 'about',
            // route level code-splitting
            // this generates a separate chunk (About.[hash].js) for this route
            // which is lazy-loaded when the route is visited.
            component: () => import('../views/AboutView.vue'),
        },
    ],
})

export default router
